
import provinceData from '../components/mpvue-citypicker/city-data/province.js'
import cityData from '../components/mpvue-citypicker/city-data/city.js'
import areaData from '../components/mpvue-citypicker/city-data/area.js'
export default {
	data() {
		return {
			provinceData,
			cityData,
			areaData
		}
	},
	methods: {
		// 根据省市区ID 获取省市区
		getDistrict(val = [], type = null) {
			let filter = val.filter(i => i)
			if (this.$util.isEmpty(filter) || filter.length < 3) {
				return ''
			} else {
				let provinceIndex = this.provinceData.findIndex(item => item.value == val[0])
				let cityIndex = this.cityData[provinceIndex].findIndex(item => item.value == val[1])
				let areaIndex = this.areaData[provinceIndex][cityIndex].findIndex(item => item.value == val[2])
				let province = this.provinceData[provinceIndex].label
				let city = this.cityData[provinceIndex][cityIndex].label
				let area = this.areaData[provinceIndex][cityIndex][areaIndex].label
				if (type == 'arr') {
					return [...new Set([province, city, area])]
				}
				if (type == 'index') {
					return [provinceIndex, cityIndex, areaIndex]
				}
				return [...new Set([province, city, area])].join('-')
			}
		}
	}
}
